package com.yrline.pay.web;

import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.google.common.collect.Maps;
import com.yrline.pay.proxy.request.CommonRequest;
import com.yrline.pay.proxy.request.SuperRequest;

@Component
public class PayUtil {

	@Value("${pay.redirectUrl}")
	private String redirectUrl;
	@Value("${pay.backInvokeUrl}")
	private String backInvokeUrl;
	
	
	private static Map<String, String> mappings = Maps.newHashMap();
	static{
		mappings.put("user.register", "1");
		mappings.put("project.regProject", "2");
		mappings.put("trade.deposit", "3");
		mappings.put("trade.freeze", "4");
		mappings.put("trade.transfer", "5");
		mappings.put("user.autoSign", "6");
		mappings.put("project.assureProject", "7");
		mappings.put("trade.unFreeze", "8");
		
		
	}
	
	public CommonRequest getDefaultRequest(SuperRequest ireq,String type){
		
		String _redirectUrl=redirectUrl+"/"+mappings.get(type);
		String _backInvokeUrl=backInvokeUrl+"/"+mappings.get(type);
		CommonRequest r = new CommonRequest();
		ireq.setS2SUrl(_backInvokeUrl);
		ireq.setWebUrl(_redirectUrl);
		r.setRequestObj(ireq);
		r.setOperationType(type);
		return r;
	}
}
